package com.tyk.bookstore.front.cart.util;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tyk.bookstore.front.cart.model.entity.CartDo;
import com.tyk.bookstore.front.cart.model.query.CartAddQuery;
import com.tyk.bookstore.front.cart.model.query.CartUpdateQuery;
import com.tyk.bookstore.front.cart.model.vo.CartPageVo;
import com.tyk.bookstore.front.cart.model.vo.ShoppingCartVo;
import com.tyk.bookstore.front.product.model.dto.Book4CartDto;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

import java.util.List;

@Mapper(componentModel = "spring")
public interface MapStructCart {
    @Mappings({@Mapping(target = "memberId", ignore = true), @Mapping(target = "checked", ignore = true), @Mapping(target = "createTime", ignore = true), @Mapping(target = "updateTime", ignore = true)})
    CartDo toCartDo(CartAddQuery query);

    @Mappings({@Mapping(target = "memberId", ignore = true), @Mapping(target = "createTime", ignore = true), @Mapping(target = "updateTime", ignore = true)})
    CartDo toCartDo(CartUpdateQuery query);

    ShoppingCartVo toShoppingCartVo(CartDo shoppingCart, Book4CartDto bookDto);

    CartPageVo toShoppingCartPageVo(Page<CartDo> page);

    @Mappings({@Mapping(target = "cover", ignore = true), @Mapping(target = "title", ignore = true), @Mapping(target = "price", ignore = true)})
    CartPageVo.ShoppingCart toShoppingCartPageVo$ShoppingCart(CartDo cartDo);

    List<ShoppingCartVo> toShoppingCartVoList(List<CartDo> doList);
}
